*** Create Figure 4A ***

********************************************************************************

** read in .dta file **

use "${clean}/who_counts_analysis.dta", clear


** Run Honest DiD Event Study for 1945-1962 subset **

preserve

gen byte D = (ANY_FOR == 1)
gen `:type year' Dyear = cond(D, YOB, 1950)

reghdfe MOB b1950.Dyear ec_total, absorb(Arabic Female geo2_ma YOB reg_fe) cluster(geo2_ma) noconstant
matrix list e(b)
label variable Dyear "year"

local plotopts ytitle("Estimate and 95% Conf. Int.") title("Effect on Registration")
coefplot, vertical yline(0) ciopts(recast(rcap)) xlabel(,angle(45)) `plotopts'
graph save "${output}/graphs/MOB_HDID_PRE62.gph", replace
graph export "${output}/graphs/MOB_HDID_PRE62.png", replace

restore

* Honest DiD Test: Schooling, ANY FOR
preserve

gen byte D = (ANY_FOR == 1)
gen `:type year' Dyear = cond(D, YOB, 1950)

reghdfe Schooling b1950.Dyear  n_schools52 n_classes52 n_students52, absorb(Arabic Female geo2_ma YOB reg_fe) cluster(geo2_ma) noconstant
matrix list e(b)
label variable Dyear "year"

local plotopts ytitle("Estimate and 95% Conf. Int.") title("Effect on Formal Schooling")
coefplot, vertical yline(0) ciopts(recast(rcap)) xlabel(,angle(45)) `plotopts'
graph save "${output}/graphs/Schooling_HDID_PRE62.gph", replace
graph export "${output}/graphs/Schooling_HDID_PRE62.png", replace

restore

* Honest DiD Test: Years, ANY FOR
preserve

gen byte D = (ANY_FOR == 1)
gen `:type year' Dyear = cond(D, YOB, 1950)

reghdfe EDU_YRS b1950.Dyear  n_schools52 n_classes52 n_students52, absorb(Arabic Female geo2_ma YOB reg_fe) cluster(geo2_ma) noconstant
matrix list e(b)
label variable Dyear "year"

local plotopts ytitle("Estimate and 95% Conf. Int.") title("Effect on Formal Schooling, Years")
coefplot, vertical yline(0) ciopts(recast(rcap)) xlabel(,angle(45)) `plotopts'
graph save "${output}/graphs/YRS_HDID_PRE62.gph", replace
graph export "${output}/graphs/YRS_HDID_PRE62.png", replace

restore

* Honest DiD Test: Lit, ANY FOR
preserve


*Excluded Groups: Provinces formerly administered by Spain, non-residents, non-citizens, those born abroad, province partially in W. Sahara

gen byte D = (ANY_FOR == 1)
gen `:type year' Dyear = cond(D, YOB, 1950)

reghdfe French_Lit b1950.Dyear  n_schools52 n_classes52 n_students52, absorb(Arabic Female geo2_ma YOB reg_fe) cluster(geo2_ma) noconstant
matrix list e(b)
label variable Dyear "year"

local plotopts ytitle("Estimate and 95% Conf. Int.") title("Effect on French & Arabic Literacy")
coefplot, vertical yline(0) ciopts(recast(rcap)) xlabel(,angle(45)) `plotopts'
graph save "${output}/graphs/LIT_HDID_PRE62.gph", replace
graph export "${output}/graphs/LIT_HDID_PRE62.png", replace

restore

** Output and Combine Figures **

graph combine "${output}/graphs/MOB_HDID_PRE62.gph" "${output}/graphs/Schooling_HDID_PRE62.gph" 
graph save "${output}/graphs/PRE_Honest62_A.gph", replace
graph export "${output}/graphs/Figure4A_A.png", replace

graph combine "${output}/graphs/YRS_HDID_PRE62.gph" "${output}/graphs/LIT_HDID_PRE62.gph"
graph save "${output}/graphs/PRE_Honest62_B.gph", replace
graph export "${output}/graphs/Figure4A_B.png", replace
